package ui.panel.equips {

	import beans.WarriorBean;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	import globals.Global;
	
	import ui.component.Button;
	import ui.component.Label;
	import ui.component.Page;
	import ui.component.TextButton;
	import ui.face.Bar;
	
	import util.UIUtil;
	
	public class WarriorEquipInfo extends Sprite {
		
		private var nameLabel:Label;
		private var jobLabel:Label;
		private var levelLabel:Label;
		private var weaponButton:TextButton;
		private var accessoryButton:TextButton;
		private var jewelButton:TextButton;
		private var otherButton:TextButton;
		
		private var warriorView:Bitmap;
		
		private var weaponGrid:Bitmap;
		private var accessGrid:Bitmap;
		private var itemGrid:Bitmap;
		
		private var warriorBean:WarriorBean;

		public function WarriorEquipInfo() {
			super();
			
			var bg:Bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("warrior_bg"));
			addChild(bg);
			
			nameLabel = new Label(14, 0xFFFFFF, true);
			nameLabel.x = 20;
			nameLabel.y = 20;
			addChild(nameLabel);
			jobLabel = new Label();
			jobLabel.x = 50;
			jobLabel.y = 30;
//			addChild(jobLabel);
			levelLabel = new Label(12, 0xFFFFFF, true);
			levelLabel.x = 84;
			levelLabel.y = 22;
			addChild(levelLabel);
			
			warriorView = new Bitmap();
			addChild(warriorView);
			
			weaponGrid = new Bitmap();
			weaponGrid.x = 25;
			weaponGrid.y = 162;
			addChild(weaponGrid);
			accessGrid = new Bitmap();
			accessGrid.x = 25;
			accessGrid.y = 202;
			addChild(accessGrid);
			itemGrid = new Bitmap();
			itemGrid.x = 25;
			itemGrid.y = 242;
			addChild(itemGrid);
			
			var label:Label;
			label = new Label(12, 0xFFFFFF);
			label.x = 30;
			label.y = 170;
			label.text = "武器";
			addChild(label);
			label = new Label(12, 0xFFFFFF);
			label.x = 30;
			label.y = 210;
			label.text = "饰品";
			addChild(label);
			label = new Label(12, 0xFFFFFF);
			label.x = 30;
			label.y = 250;
			label.text = "道具";
			addChild(label);
			
			weaponButton = UIUtil.getTextButton("强化", ["button_green_off", "button_green_on", "button_green_off"], weaponHandler);
			weaponButton.x = 70;
			weaponButton.y = 166;
			addChild(weaponButton);
			
			accessoryButton = UIUtil.getTextButton("强化", ["button_green_off", "button_green_on", "button_green_off"], accessoryHandler);
			accessoryButton.x = 70;
			accessoryButton.y = 206;
			addChild(accessoryButton);
			
			jewelButton = UIUtil.getTextButton("强化", ["button_green_off", "button_green_on", "button_green_off"], jewelHandler);
			jewelButton.x = 70;
			jewelButton.y = 246;
			addChild(jewelButton);
			
			otherButton = UIUtil.getTextButton("查看其它", ["button_yellow_off", "button_yellow_on", "button_yellow_off"], otherHandler);
			otherButton.x = 50;
			otherButton.y = 286;
			addChild(otherButton);
			
			var bean:WarriorBean = new WarriorBean();
			bean.name = "阿波罗";
			bean.job = "太阳神";
			bean.image = "avatar_1_1";
			bean.level = 10;
			bean.exp = 20;
			bean.power = 300;
			bean.magic = 400;
			update(bean);
		}
		
		private function weaponHandler(button:TextButton):void {
			
		}
		
		private function accessoryHandler(button:TextButton):void {
			
		}
		
		private function jewelHandler(button:TextButton):void {
			
		}
		
		private function otherHandler(button:TextButton):void {
			
		}
		
		private function presenceHandler(button:Button):void {
			if (warriorBean != null) {
			}
		}
		
		public function update(bean:WarriorBean):void {
			warriorBean = bean;
			
			nameLabel.text = bean.name;
			jobLabel.text = bean.job;
			levelLabel.text = "等级:" + bean.level.toString();
			warriorView.bitmapData = Global.assetsManager.getAssetsAsBitmapData(bean.image, "warrior");
			warriorView.x = warriorView.width * 0.5 + 10;
			warriorView.y = warriorView.height - 40;
			
			weaponGrid.bitmapData = accessGrid.bitmapData = itemGrid.bitmapData = Global.assetsManager.getAssetsAsBitmapData("grid_s");
		}
		
		private function pageHandler(num:uint):void {
			
		}
		
		public function clear():void {
			warriorBean = null;
			
			nameLabel.text = jobLabel.text = levelLabel.text = "";
			warriorView.bitmapData = null;
		}
	}
}